﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using QLKTX1._0.DAO;
using QLKTX1._0.DTO;

namespace QLKTX1._0.GUI
{
    public partial class FrmThemDsPhong : Form
    {
        //public PhongDTO phongMoi;       

        public FrmThemDsPhong()
        {
            InitializeComponent();
          
            
        }

        private void FrmThemDsPhong_Load(object sender, EventArgs e)
        {


           // lbthem.Text = "Chọn các thuộc tính để thêm mới";


            cmbKhu.DataSource = KhuDAO.dsKhu();
            cmbKhu.DisplayMember = "tenKhu";
            cmbKhu.ValueMember = "maKhu";

            cmbTang.DataSource = TangDAO.dsTang();
            cmbTang.DisplayMember = "tenTang";
            cmbTang.ValueMember = "maTang";

            cmbTenPhong.DataSource = TenPhongDAO.dsTenPhong();
            cmbTenPhong.DisplayMember = "soPhong";
            cmbTenPhong.ValueMember = "maTenPhong";

            cmbSoGiuong.DataSource = SoGiuongDAO.dsSoGiuong();
            cmbSoGiuong.DisplayMember = "soLuong";
            cmbSoGiuong.ValueMember = "maSG";
        }

        private void btnThoat_Click(object sender, EventArgs e)
        {
            
        }

        private void btnThoat_Click_1(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnLuu_Click(object sender, EventArgs e)
        {
            //FrmDsPhong frm = new FrmDsPhong();
            PhongDTO p = new PhongDTO();

            string khu = cmbKhu.SelectedValue.ToString();
            KhuDTO k = new KhuDTO();
            k.MaKhu = khu;
          //  k.TenKhu = khu;

            string tang = cmbTang.SelectedValue.ToString();
            TangDTO t = new TangDTO();
            t.MaTang = tang;
           // t.tenTang = tang;

            int tenPhong = Int32.Parse (cmbTenPhong.SelectedValue.ToString());
            TenPhongDTO tp = new TenPhongDTO();
            tp.MaTenPhong = tenPhong;
           // tp.SoPhong = tenPhong.ToString ();

            string  soGiuong = cmbSoGiuong.SelectedValue.ToString();
            SoGiuongDTO sg = new SoGiuongDTO();
            sg.MaSG = soGiuong;
           // sg.SoLuong = Int32.Parse (soGiuong);
            
            p.MaKhu = k;
            p.MaTang = t;
            p.MaTenPhong = tp;
            p.MaSoGiuong = sg;

            //this.phongMoi = p;
            //this.PhongThem = p;


        }
    }
}
